#include<iostream>
#include<map>

using namespace std;

const int N=101;
 int q[N];

int main(){
	freopen("input.txt","r",stdin);
	int n;
	cin>>n;
	map<int,int,greater<int>> m;
	for(int i=0;i<n;i++){
		cin>>q[i];
		if(m[q[i]]==0){
		while(q[i]!=1){
			if(q[i]%2==0){
				q[i]=q[i]/2;
			}else if(q[i]%2==1){
				q[i]=(3*q[i]+1)/2;
			}
			if(m[q[i]]!=0){
				break;
			}
			m[q[i]]++;
		}}
		else{
			continue;
		}
	}
	int first=0;
	for(auto i: m){
		if(i.second==0){
			if(first){
				cout<<" "<<i.first;
			}
			else{
				cout<<i.first;
				first=1;
			}
		}
	}

}